Table of Contents

Module: Code .\src\TW\Utils\Code.py

Bytecode inspection and patching - like a simpler (faster!) bytecodehacks

Similar to the Python bytecodehacks package, this module supplies Code and Function objects which are mutable versions of the real things. The main difference between this module and bytecodehacks is that this module values speed above nearly all other considerations, and thus only offers in-place bytecode patching, and eschews most of the higher-level facilities offered by bytecodehacks. But it's plenty enough for what TransWarp needs.

The module makes available many useful values; you can get any opcode as a constant from it by explicit import, such as:

        from TW.Utils.Code import LOAD_NAME, STORE_NAME

There's also an opcode array that you can import that maps opcode names to values.

Currently, this package still works on Python 2.1... as long as you have ExtensionClass installed. But that's not officially supported, so don't count on it staying that way forever.

Imported modules   
from array import array
from dis import HAVE_ARGUMENT, EXTENDED_ARG, opname
import new
from types import CodeType, StringType
Functions   
_bindAll
bind_func
copy_func
show
visit
  _bindAll 
_bindAll ( f )

  bind_func 
bind_func ( func,  **kw )

  copy_func 
copy_func ( func )

  show 
show (
        code,
        path,
        newconsts,
        )

  visit 
visit (
        code,
        visitFunc=None,
        path=(),
        )

Classes   
Code
Function
FunctionBinder
codeIndex
codeIter

Table of Contents

This document was automatically generated on Tue Mar 05 10:33:49 2002 by HappyDoc version WORKING